package com.example.workflow.listener;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.TaskListener;
import org.springframework.beans.factory.annotation.Autowired;

public class TaskCCreateListener implements TaskListener {
    @Autowired
    private RuntimeService runtimeService;
    @Override
    public void notify(DelegateTask task) {
//        // 判断是否需要启动任务D
//        boolean needsD = (boolean) task.getVariable("needsD");
//        if (needsD) {
//            String processInstanceId = task.getProcessInstanceId();
//
//            // 动态修改流程实例，添加任务D分支
//            runtimeService.createProcessInstanceModification(processInstanceId)
////                    .cancelAllForActivity("dummyEnd")       // 取消默认的虚拟分支
//                    .startBeforeActivity("Activity_0ma321h")           // 启动任务D分支
//                    .execute();
//        }


            task.setVariable("needHelp", false);

    }
}
